/*********************************************************************
Replication Materials for "Explanation Giving Promotes Democratic Satisfaction Regardless of Respondent Partisanship"

Syntax produces the models discussed in Online Appendix B. 
***********************************************************************/

/*******************
Working Directory and Data
Update working directory to where you have the data
********************/

cd "C:\Users\jar68\OneDrive\Ongoing Work\Explanations and Dem Support\P. Behavior\Revision\R2\RR3\FINAL\Dataverse\"
use "ess_final.dta"

**Dropping non-democracies; Bulgaria had caretaker gov't
drop if country == "Albania" | country == "Russia" | country == "Kosovo" | country == "Ukraine" | country == "Bulgaria"

/*********************************
Weights
*********************************/

gen anweight = pspwght*pweight
label var anweight "Analysis Weight"


/**********************************
Table OB1
***********************************/

***Models
eststo clear
local conts " std_courts std_elections std_econ std_life std_socialtrust i.ideol_ext1 std_ladder std_educ c.age i.gender i.minority i.citizen"
**Government Satisfaction
*In-Text
eststo: mixed gov_satis std_explains reason_std i.co_partisan i.east_europe c.enep_comb c.unemp_ch  `conts' [pweight=anweight]  || country:
*Alternative Measure of Party System & Democracy Level
eststo: mixed gov_satis std_explains reason_std i.co_partisan libdem i.legtype1 c.unemp_ch `conts' [pweight=anweight]  || country: 
*Inequality Rather than Unemployment 
eststo: mixed gov_satis std_explains reason_std i.co_partisan libdem i.legtype1 gini_disp `conts' [pweight=anweight]  || country: 

**Dem
*In-Text
eststo: mixed dem_satis std_explains reason_std i.co_partisan i.east_europe c.enep_comb c.unemp_ch  `conts' [pweight=anweight]  || country:
*Alternative Measure of Democracy & Legislative Type
eststo: mixed dem_satis std_explains reason_std i.co_partisan libdem i.legtype1 c.unemp_ch `conts' [pweight=anweight]  || country: 
*Inequality Rather than Unemployment
eststo: mixed dem_satis std_explains reason_std i.co_partisan libdem i.legtype1 gini_disp `conts' [pweight=anweight]  || country: 


***Table
esttab using table_ob1.rtf, label onecell replace se b(3) aic bic nobaselevels ///
		transform(ln*: exp(2*@) 2*exp(2*@)) ///
		eqlabels("" "var(Constant)" "var(Residual)", none) ///
		mtitles("Gov" "Gov" "Gov" "Dem" "Dem" "Dem") ///
		title("{\b Table OB1}: Explanation Giving and Political Support, Alternative Country Controls") ///
		addnotes("DV ranges from 0-10. All continuous variables are country-standardized save for age in years. Analyses use survey weights.") ///
		keep(std_explains reason_std 1.east_europe enep_comb unemp_ch libdem_std 1.legtype1 gini_disp)


/**********************************
Table OB2
***********************************/

***Models
eststo clear
local conts " std_courts std_elections std_econ std_life std_socialtrust i.ideol_ext1 std_ladder std_educ c.age i.gender i.minority i.citizen"
**Government Satisfaction
*In-Text
eststo: mixed gov_satis c.std_explains##i.co_partisan c.reason_std##i.co_partisan i.east_europe c.enep_comb c.unemp_ch  `conts' [pweight=anweight]  || country:
*Alternative Measure of Party System & Democracy Level
eststo: mixed gov_satis c.std_explains##i.co_partisan c.reason_std##i.co_partisan libdem i.legtype1 c.unemp_ch `conts' [pweight=anweight]  || country: 
*Inequality Rather than Unemployment 
eststo: mixed gov_satis c.std_explains##i.co_partisan c.reason_std##i.co_partisan libdem i.legtype1 gini_disp `conts' [pweight=anweight]  || country: 

**Dem
*In-Text
eststo: mixed dem_satis c.std_explains##i.co_partisan c.reason_std##i.co_partisan i.east_europe c.enep_comb c.unemp_ch  `conts' [pweight=anweight]  || country:
*Alternative Measure of Democracy & Legislative Type
eststo: mixed dem_satis c.std_explains##i.co_partisan c.reason_std##i.co_partisan libdem i.legtype1 c.unemp_ch `conts' [pweight=anweight]  || country: 
*Inequality Rather than Unemployment
eststo: mixed dem_satis c.std_explains##i.co_partisan c.reason_std##i.co_partisan libdem i.legtype1 gini_disp `conts' [pweight=anweight]  || country: 

		
***Table
esttab using table_ob2.rtf, label onecell replace se b(3) aic bic nobaselevels ///
		transform(ln*: exp(2*@) 2*exp(2*@)) ///
		eqlabels("" "var(Constant)" "var(Residual)", none) ///
		mtitles("Gov" "Gov" "Gov" "Dem" "Dem" "Dem") ///
		title("{\b Table OB2}: Explanation Giving and Political Support, Alternative Country Controls; Moderation Analyses") ///
		addnotes("DV ranges from 0-10. Analyses use survey weights.") ///
		drop(std_courts std_elections std_econ std_econ std_life std_socialtrust 1.ideol_ext1 2.ideol_ext1 3.ideol_ext1 4.ideol_ext1 5.ideol_ext1 6.ideol_ext1 ///
			 std_ladder std_educ age 1.gender 1.minority 1.citizen) 
		
/**********************************
Table OB3
***********************************/

***Models
eststo clear
local conts " std_courts std_elections std_econ std_life std_socialtrust i.ideol_ext1 std_ladder std_educ c.age i.gender i.minority i.citizen i.east_europe c.enep_comb c.unemp_ch"
foreach var in gov_satis dem_satis {
	*In-Text Model
	eststo: mixed `var' std_explains reason_std i.co_partisan `conts'  [pweight=anweight] || country: 
	*+ Ethnic Heterogeneity
	eststo: mixed `var' std_explains reason_std i.co_partisan EFindex `conts'  [pweight=anweight] || country: 
	*+ Unionization
	eststo: mixed `var' std_explains reason_std i.co_partisan unionization1 `conts'  [pweight=anweight] || country: 
	*+ Nordic
	eststo: mixed `var' std_explains reason_std i.co_partisan i.nordic `conts'  [pweight=anweight] || country: 
}

***Full Table
esttab using table_ob3.rtf, label onecell replace se b(3) aic bic nobaselevels ///
		transform(ln*: exp(2*@) 2*exp(2*@)) ///
		eqlabels("" "var(Constant)" "var(Residual)", none) ///
		mtitles("Gov" "Gov" "Gov" "Gov" "Dem" "Dem" "Dem" "Dem") ///
		title("{\b Table OB3}: Explanation Giving and Political Support - Additional Country Controls") ///
		addnotes("DV ranges from 0-10. All continuous variables are country-standardized save for age in years. Analyses use survey weights.")

/**********************************
Table OB4
***********************************/

eststo clear
local conts " std_courts std_elections std_econ std_life std_socialtrust i.ideol_ext1 std_ladder std_educ c.age i.gender i.minority i.citizen i.east_europe c.enep_comb c.unemp_ch"
foreach var in gov_satis dem_satis {
	*In-Text
	eststo: mixed `var' c.std_explains##i.co_partisan c.reason_std##i.co_partisan `conts' [pweight=anweight] || country: 
	*+ Ethnic Heterogeneity
	eststo: mixed `var' c.std_explains##i.co_partisan c.reason_std##i.co_partisan EFindex `conts' [pweight=anweight] || country:
	*+ Unionization
	eststo: mixed `var' c.std_explains##i.co_partisan c.reason_std##i.co_partisan unionization1 `conts' [pweight=anweight] || country:
	*+ Nordic
	eststo: mixed `var' c.std_explains##i.co_partisan c.reason_std##i.co_partisan i.nordic `conts' [pweight=anweight] || country:
}

***Full Table
esttab using table_ob4.rtf, label onecell replace se b(3) aic bic nobaselevels ///
		transform(ln*: exp(2*@) 2*exp(2*@)) ///
		eqlabels("" "var(Constant)" "var(Residual)", none) ///
		mtitles("Gov" "Gov" "Gov" "Gov" "Dem" "Dem" "Dem" "Dem") ///
		title("{\b Table OB4}: Explanation Giving and Political Support") ///
		addnotes("DV ranges from 0-10. All continuous variables are country-standardized save for age in years. Analyses use survey weights.")


		

